package com.glory.brepda.adapter;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.view.View;

import androidx.annotation.Nullable;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.glory.brepda.R;
import com.glory.brepda.activity.technicalservice.AMDetailActivity;
import com.glory.brepda.entity.AbnormalMaintenanceBean;

import java.util.List;

public class AbnormalMaintenanceAdapter extends BaseQuickAdapter<AbnormalMaintenanceBean.XPMSABNORMALHANDLEFORMSDTO, BaseViewHolder> {

    private Activity activity;

    public AbnormalMaintenanceAdapter(@Nullable List<AbnormalMaintenanceBean.XPMSABNORMALHANDLEFORMSDTO> data, Activity activity) {
        super(R.layout.adapter_abnrmal_maintenance,data);
        this.activity = activity;

    }

    @Override
    protected void convert(BaseViewHolder helper, AbnormalMaintenanceBean.XPMSABNORMALHANDLEFORMSDTO item) {

        helper.setText(R.id.position,String.valueOf(helper.getAdapterPosition()+1));
        helper.setText(R.id.EQUIPMENTID,item.getEQUIPMENTID());
        helper.setText(R.id.SHEETNAME,item.getSHEETNAME());
        helper.setText(R.id.CHECKRESULT,item.getCHECKRESULT());

        helper.itemView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {

                Context context = helper.itemView.getContext();
                Intent intent = new Intent(context, AMDetailActivity.class);
                intent.putExtra("amMessage", item); // 传递数据
                activity.startActivityForResult(intent,1);
            }
        });

    }


}
